import 'package:flutter/material.dart';

// ignore: must_be_immutable
class CommonContainer extends StatelessWidget {
  final Widget child;
  EdgeInsetsGeometry margin;
  EdgeInsetsGeometry padding;
  Color colorBg;
  Color colorBorder;
  final double radiusCircular;

  CommonContainer(this.child,
      {this.margin = const EdgeInsets.all(16),
      this.padding = const EdgeInsets.fromLTRB(16, 6, 16, 6),
      this.colorBg = Colors.white,
      this.colorBorder = const Color(0xFFEEEEEE),
      this.radiusCircular = 8}); // Widget widget,

  @override
  Container build(BuildContext context) {
    return Container(
      margin: margin, //EdgeInsets.fromLTRB(20, 0, 20, 20),
      padding: padding, child: child,
      decoration: BoxDecoration(
          color: colorBg,
          border: Border.all(color: colorBorder, width: 1),
          borderRadius: BorderRadius.all(Radius.circular(radiusCircular))),
    );
  }

  static Widget item(
      BuildContext context, String title, String image, Widget widget,
      [double imageSize = 28,
      EdgeInsetsGeometry margin = const EdgeInsets.fromLTRB(20, 20, 20, 20)]) {
    return CommonContainer(
        GestureDetector(
            behavior: HitTestBehavior.translucent,
            onTap: () {
              Navigator.push(
                  context, MaterialPageRoute(builder: (context) => widget));
            },
            child: Row(children: <Widget>[
              Image.asset(image, width: imageSize, height: imageSize),
              Expanded(
                  flex: 1,
                  child: Container(
                      margin: EdgeInsets.only(left: 18),
                      child: Text(title, style: TextStyle(fontSize: 18)))),
              Icon(Icons.arrow_forward_ios, color: Color(0xFFAAAAAA))
            ])),
        margin: EdgeInsets.only(top: 12),
        padding: EdgeInsets.all(16));
  }

  static Widget loadingView({double h = 450}) {
    return Container(
        width: double.infinity,
        height: h,
        alignment: Alignment.center,
        child: const CircularProgressIndicator());
  }

  static Widget uploadingView({double w = double.maxFinite, double h = 15}) {
    return Container(
        width: w,
        height: h,
        alignment: Alignment.center,
        child: const LinearProgressIndicator());
  }
}
